package com.xsir.ditan.miniprogram.service.impl;

import com.xsir.ditan.miniprogram.entity.Banner;
import com.xsir.ditan.miniprogram.mapper.BannerMapper;
import com.xsir.ditan.miniprogram.service.IBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xsir
 * @since 2021-02-01
 */
@Service
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements IBannerService {
    @Autowired
    private BannerMapper bannerMapper;
    
    @Override
    public List<Banner> listByGroup(int count) {
        List<Banner> list = bannerMapper.group(0, count);
        if(Objects.isNull(list)) {
            list = Collections.emptyList();
        }
        return list;
    }
}
